package com.example.musicdemo.ui.fragment

import android.content.Intent
import android.os.Bundle
import android.preference.Preference
import android.preference.PreferenceFragment
import android.preference.PreferenceScreen
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.musicdemo.R
import com.example.musicdemo.ui.activity.AboutActivity

class SettingFragment : PreferenceFragment() {


    override fun onCreateView(
        inflater: LayoutInflater?,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        addPreferencesFromResource(R.xml.setting)


        return super.onCreateView(inflater, container, savedInstanceState)
    }


    override fun onPreferenceTreeClick(
        preferenceScreen: PreferenceScreen?,
        preference: Preference?
    ): Boolean {

        val key = preference?.key
        if ("about" .equals(key) ){
            activity?.startActivity(Intent(context, AboutActivity::class.java))
        }

        return super.onPreferenceTreeClick(preferenceScreen, preference)


    }
}